package com.sxu.greedy.day1;

/**
 * 柠檬水找零
 */
public class Test1 {
    public boolean lemonadeChange(int[] bills) {
        int ten = 0;
        int five = 0;
        for(int x : bills){
            if(x == 5){
                five++;
            } else if (x == 10) {
                if(five == 0){
                    return false;
                }
                five--;
                ten++;
            } else {
                if(five != 0 && ten !=0){
                    ten --;
                    five --;
                } else if (five >= 3) {
                    five -= 3;
                } else {
                    return false;
                }
            }
        }
        return true;
    }
}
